<?php

function GFCIWidget_Login($args) {
$options = get_option(GFCI_LOGIN_WIDGET);
	$gadget_wid = attribute_escape($options['gadget_wid']);
	$gadget_hei = attribute_escape($options['gadget_hei']);
	$content_bkgd = attribute_escape($options['content_bkgd']);
	$content_text = attribute_escape($options['content_text']);
	$content_links = attribute_escape($options['content_links']);
	$gfci_border = attribute_escape($options['gfci_border']);
	$canvas_path = get_option( gfci_canvas_path );
extract($args);
  echo $before_widget;
  echo $before_title;
  echo $after_title;
?>
<div id="gfci-login" style="width:<?php echo $gadget_wid; ?>px;border:1px solid #<?php echo $gfci_border; ?>;"></div>
<script type="text/javascript">
var skin = {};
skin['BORDER_COLOR'] = '#333333';
skin['ENDCAP_BG_COLOR'] = '#e0ecff';
skin['ENDCAP_TEXT_COLOR'] = '#333333';
skin['ENDCAP_LINK_COLOR'] = '#0000cc';
skin['ALTERNATE_BG_COLOR'] = '#ffffff';
skin['CONTENT_BG_COLOR'] = '<?php echo $content_bkgd; ?>';
skin['CONTENT_LINK_COLOR'] = '<?php echo $content_links; ?>';
skin['CONTENT_TEXT_COLOR'] = '<?php echo $content_text; ?>';
skin['CONTENT_SECONDARY_LINK_COLOR'] = '#7777cc';
skin['CONTENT_SECONDARY_TEXT_COLOR'] = '#666666';
skin['CONTENT_HEADLINE_COLOR'] = '#333333';
skin['ALIGNMENT'] = '<?php echo $gadget_hei; ?>';
google.friendconnect.container.setParentUrl('<?php echo $canvas_path; ?>' /* location of rpc_relay.html and canvas.html */);
google.friendconnect.container.renderSignInGadget(
 { id: 'gfci-login',
   site: '<?php echo gfci_sit(); ?>'},
  skin);
</script>
<?php
  echo $after_widget;
}

function widget_gfci_login_control() {
  $options = get_option(GFCI_LOGIN_WIDGET);
  if (!is_array($options)) {
    $options = array();
  }

  $widget_data = $_POST[GFCI_LOGIN_WIDGET];
  if ($widget_data['submit']) {
    $options['gadget_wid'] = $widget_data['gadget_wid'];
    $options['gadget_hei'] = $widget_data['gadget_hei'];
    $options['content_bkgd'] = $widget_data['content_bkgd'];
    $options['content_text'] = $widget_data['content_text'];
    $options['content_links'] = $widget_data['content_links'];
    $options['gfci_border'] = $widget_data['gfci_border'];

    update_option(GFCI_LOGIN_WIDGET, $options);
  }

  // Render form
  $gadget_wid = $options['gadget_wid'];
  $gadget_hei = $options['gadget_hei'];
  $content_bkgd = $options['content_bkgd'];
  $content_text = $options['content_text'];
  $content_links = $options['content_links'];
  $gfci_border = $options['gfci_border'];
  
?>
<table>
<tr>
<td>
<h3>Width / Alignment</h3>
<table>
<tr>
<td><label for="<?php echo GFCI_LOGIN_WIDGET; ?>-gadget-wid">
  Width:
  </label></td>
<td><input class="widefat" 
    type="text"
    name="<?php echo GFCI_LOGIN_WIDGET; ?>[gadget_wid]" 
    id="<?php echo GFCI_LOGIN_WIDGET; ?>-gadget-wid" 
    value="<?php echo $gadget_wid; ?>"/></td>
</tr>
<tr>
<td><label for="<?php echo GFCI_LOGIN_WIDGET; ?>-gadget-hei">
  <b>left</b>, <b>right</b>, or <b>center</b>:
  </label></td>
<td><input class="widefat" type="text" 
    name="<?php echo GFCI_LOGIN_WIDGET; ?>[gadget_hei]" 
    id="<?php echo GFCI_LOGIN_WIDGET; ?>-gadget-hei" 
    value="<?php echo $gadget_hei; ?>"/></td>
</tr>
</table>
</td>
<td>
<h3>Color Settings</h3>
<table>
<tr><td>Format Example:</td><td><b>FFFFFF</b></td></tr>
<tr><td><label for="<?php echo GFCI_LOGIN_WIDGET; ?>-content-bkgd">
Content Bkgd:</label></td>
<td><input class="widefat"
    name="<?php echo GFCI_LOGIN_WIDGET; ?>[content_bkgd]"
    type="text"
    id="<?php echo GFCI_LOGIN_WIDGET; ?>-content-bkgd"
    value="<?php echo $content_bkgd; ?>"
    size="7"/></td>
</tr>
<tr><td><label for="<?php echo GFCI_LOGIN_WIDGET; ?>-content-text">
Content Text:</label></td>
<td><input class="widefat"
    name="<?php echo GFCI_LOGIN_WIDGET; ?>[content_text]"
    type="text"
    id="<?php echo GFCI_LOGIN_WIDGET; ?>-content-text"
    value="<?php echo $content_text; ?>"
    size="7"/></td>
</tr>
<tr><td><label for="<?php echo GFCI_LOGIN_WIDGET; ?>-content-links">
Content Links:</label></td>
<td><input class="widefat"
    name="<?php echo GFCI_LOGIN_WIDGET; ?>[content_links]"
    type="text"
    id="<?php echo GFCI_LOGIN_WIDGET; ?>-content-links"
    value="<?php echo $content_links; ?>"
    size="7"/></td>
</tr>
<tr><td><label for="<?php echo GFCI_LOGIN_WIDGET; ?>-gfci-border">
Border:</label></td>
<td><input class="widefat"
    name="<?php echo GFCI_LOGIN_WIDGET; ?>[gfci_border]"
    type="text"
    id="<?php echo GFCI_LOGIN_WIDGET ;?>-gfci-border"
    value="<?php echo $gfci_border; ?>"
    size="7"/></td>
</tr>
</table></td></tr></table>
<input type="hidden" 
  name="<?php echo GFCI_LOGIN_WIDGET; ?>[submit]" 
  value="1"/>
<?php
}

?>
